package Character;

import org.json.JSONObject;

import GameTools.ydPoint;
import android.graphics.Canvas;

import com.ydDev.charateranimation.R;

public class Head {
	BodyPart head;

	public Head(ydPoint position) {
		head = new BodyPart(position, R.drawable.gc1_head);

/*		head.setFirstJoint(new ydPoint(head.limb.p1.x-29.5f, head.limb.p1.y + 43));
		head.setSecondJoint(new ydPoint(head.limb.p1.x-29.5f, head.limb.p2.y-5));*/
		
		setJoints();

	}
	
	public void setJoints(){
		head.setFirstJoint(new ydPoint(head.limb.p1.x- 0.188f*head.skin.getWidth(), head.limb.p1.y + 0.279f*head.skin.getWidth()));
		head.setSecondJoint(new ydPoint(head.limb.p1.x- 0.188f*head.skin.getWidth(), head.limb.p1.y+ 0.990f*head.skin.getWidth()));
	}

	public void draw(Canvas canvas) {
		head.draw(canvas);
	}

	public void rotateArm(double rads, int mode) {
		if (mode == 0) {
			head.rotate(rads);

		}
	}
	
	public void deltaMove(ydPoint shift){
		head.deltaMove(shift);
	}

	public void loadPostion(JSONObject json) {
		head.limb.setPosition(ydPoint.stringPairToydPoint(json.optString("p1")), ydPoint.stringPairToydPoint(json.optString("p2")));
		head.j1.setCoordinates(ydPoint.stringPairToydPoint(json.optString("j1")));
		head.j2.setCoordinates(ydPoint.stringPairToydPoint(json.optString("j2")));
		
	}

	public void setScale(float s) {
		head.setScale(s);
		setJoints();
	}

	public void moveTo(ydPoint p) {
		head.moveTo(p);
		
	}

}
